package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CollectionManag;
import com.ruoyi.system.service.ICollectionManagService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收付款管理Controller
 * 
 * @author LP
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/system/manag")
public class CollectionManagController extends BaseController
{
    @Autowired
    private ICollectionManagService collectionManagService;

    /**
     * 查询收付款管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:manag:list')")
    @GetMapping("/list")
    public TableDataInfo list(CollectionManag collectionManag)
    {
        startPage();
        List<CollectionManag> list = collectionManagService.selectCollectionManagList(collectionManag);
        return getDataTable(list);
    }

    /**
     * 导出收付款管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:manag:export')")
    @Log(title = "收付款管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CollectionManag collectionManag)
    {
        List<CollectionManag> list = collectionManagService.selectCollectionManagList(collectionManag);
        ExcelUtil<CollectionManag> util = new ExcelUtil<CollectionManag>(CollectionManag.class);
        util.exportExcel(response, list, "收付款管理数据");
    }

    /**
     * 获取收付款管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:manag:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(collectionManagService.selectCollectionManagById(id));
    }

    /**
     * 新增收付款管理
     */
    @PreAuthorize("@ss.hasPermi('system:manag:add')")
    @Log(title = "收付款管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CollectionManag collectionManag)
    {
        return toAjax(collectionManagService.insertCollectionManag(collectionManag));
    }

    /**
     * 修改收付款管理
     */
    @PreAuthorize("@ss.hasPermi('system:manag:edit')")
    @Log(title = "收付款管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CollectionManag collectionManag)
    {
        return toAjax(collectionManagService.updateCollectionManag(collectionManag));
    }

    /**
     * 删除收付款管理
     */
    @PreAuthorize("@ss.hasPermi('system:manag:remove')")
    @Log(title = "收付款管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(collectionManagService.deleteCollectionManagByIds(ids));
    }
}
